# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=arm-- -run-pass=machine-outliner -verify-machineinstrs \
# RUN: %s -o - | FileCheck %s

--- |
  define void @outline_save_reg_arm() #0 { ret void }
  define void @outline_save_reg_thumb() #1 { ret void }
  declare void @z()

  attributes #0 = { minsize optsize }
  attributes #1 = { minsize optsize "target-features"="+armv7-a,+thumb-mode" }
...
---

name:           outline_save_reg_arm
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_save_reg_arm
  ; CHECK: bb.0:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r6 = MOVr killed $lr, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK:   $lr = MOVr killed $r6, 14 /* CC::al */, $noreg, $noreg
  ; CHECK: bb.1:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r6 = MOVr killed $lr, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK:   $lr = MOVr killed $r6, 14 /* CC::al */, $noreg, $noreg
  ; CHECK: bb.2:
  ; CHECK:   liveins: $lr
  ; CHECK:   early-clobber $sp = frame-setup STR_PRE_IMM killed $lr, $sp, -8, 14 /* CC::al */, $noreg
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK:   $lr, $sp = frame-destroy LDR_POST_IMM $sp, $noreg, 8, 14 /* CC::al */, $noreg
  ; CHECK: bb.3:
  ; CHECK:   liveins: $lr, $r0, $r6, $r7, $r8, $r9, $r10, $r11
  ; CHECK:   $r6 = MOVr killed $lr, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   BL @OUTLINED_FUNCTION_1
  ; CHECK:   $lr = MOVr killed $r6, 14 /* CC::al */, $noreg, $noreg
  ; CHECK: bb.4:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r2 = MOVr $lr, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   BX_RET 14 /* CC::al */, $noreg
  bb.0:
    liveins: $lr
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
    $r5 = MOVi 1, 14, $noreg, $noreg
  bb.1:
    liveins: $lr
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
    $r5 = MOVi 1, 14, $noreg, $noreg
  bb.2:
    liveins: $lr
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
    $r5 = MOVi 1, 14, $noreg, $noreg
  bb.3:
    liveins: $lr, $r0, $r6, $r7, $r8, $r9, $r10, $r11
    $r0 = MOVi 1, 14, $noreg, $noreg
    $r1 = MOVi 1, 14, $noreg, $noreg
    $r2 = MOVi 1, 14, $noreg, $noreg
    $r3 = MOVi 1, 14, $noreg, $noreg
    $r4 = MOVi 1, 14, $noreg, $noreg
    $r5 = MOVi 1, 14, $noreg, $noreg
  bb.4:
    liveins: $lr
    $r2 = MOVr $lr, 14, $noreg, $noreg
    BX_RET 14, $noreg
...
---

name:           outline_save_reg_thumb
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: outline_save_reg_thumb
  ; CHECK: bb.0:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r6 = tMOVr killed $lr, 14 /* CC::al */, $noreg
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_0
  ; CHECK:   $lr = tMOVr killed $r6, 14 /* CC::al */, $noreg
  ; CHECK: bb.1:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r6 = tMOVr killed $lr, 14 /* CC::al */, $noreg
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_0
  ; CHECK:   $lr = tMOVr killed $r6, 14 /* CC::al */, $noreg
  ; CHECK: bb.2:
  ; CHECK:   liveins: $lr
  ; CHECK:   early-clobber $sp = frame-setup t2STR_PRE killed $lr, $sp, -8, 14 /* CC::al */, $noreg
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_0
  ; CHECK:   $lr, $sp = frame-destroy t2LDR_POST $sp, 8, 14 /* CC::al */, $noreg
  ; CHECK: bb.3:
  ; CHECK:   liveins: $lr, $r0, $r6, $r7
  ; CHECK:   $r6 = tMOVr killed $lr, 14 /* CC::al */, $noreg
  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_0
  ; CHECK:   $lr = tMOVr killed $r6, 14 /* CC::al */, $noreg
  ; CHECK: bb.4:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r2 = tMOVr $lr, 14 /* CC::al */, $noreg
  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg
  bb.0:
    liveins: $lr
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
    $r3 = t2MOVi 1, 14, $noreg, $noreg
    $r4 = t2MOVi 1, 14, $noreg, $noreg
    $r5 = t2MOVi 1, 14, $noreg, $noreg
  bb.1:
    liveins: $lr
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
    $r3 = t2MOVi 1, 14, $noreg, $noreg
    $r4 = t2MOVi 1, 14, $noreg, $noreg
    $r5 = t2MOVi 1, 14, $noreg, $noreg
  bb.2:
    liveins: $lr
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
    $r3 = t2MOVi 1, 14, $noreg, $noreg
    $r4 = t2MOVi 1, 14, $noreg, $noreg
    $r5 = t2MOVi 1, 14, $noreg, $noreg
  bb.3:
    liveins: $lr, $r0, $r6, $r7, $r8, $r9, $r10, $r11
    $r0 = t2MOVi 1, 14, $noreg, $noreg
    $r1 = t2MOVi 1, 14, $noreg, $noreg
    $r2 = t2MOVi 1, 14, $noreg, $noreg
    $r3 = t2MOVi 1, 14, $noreg, $noreg
    $r4 = t2MOVi 1, 14, $noreg, $noreg
    $r5 = t2MOVi 1, 14, $noreg, $noreg
  bb.4:
    liveins: $lr
    $r2 = tMOVr $lr, 14, $noreg
    tBX_RET 14, $noreg

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_0
  ; CHECK: bb.0:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r0 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r3 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r4 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r5 = t2MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg

  ; CHECK-LABEL: name: OUTLINED_FUNCTION_1
  ; CHECK: bb.0:
  ; CHECK:   liveins: $lr
  ; CHECK:   $r0 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r1 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r2 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r3 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r4 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   $r5 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
  ; CHECK:   MOVPCLR 14 /* CC::al */, $noreg

